package com.ywb.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.HashMap;

/**
 * @Author ywb
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Result {
    private Integer code;
    private boolean success;
    private String message;
    private HashMap<String, Object> data;

    public static Result success(){
        return new Result().setSuccess(true).setCode(200);
    }
    public static Result success(String key, Object value){
        HashMap<String, Object> dataMap = new HashMap<>();
        dataMap.put(key, value);
        return success().setData(dataMap);
    }
    public static Result error(){
        return new Result().setSuccess(false).setCode(400);
    }
    public static Result error(String message){
        return error().setMessage(message);
    }

}
